home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 014 / uasmls.arc / UASM-JMP.BAS (.txt) < prev    next >
Encoding:
GW-BASIC  |  1985-09-02  |  9.0 KB  |  171 lines

  1. 10  '--------------------------------------------------------------------------
  2. 11  '|<UNK! {0009}>UASM-JMP  1.12<UNK! {0009}><UNK! {0009}>20 Nov., 1983<UNK! {0009}><UNK! {0009}>White Crane Systems  |
  3. 12  '|<UNK! {0009}>copyright 1983<UNK! {0009}><UNK! {0009}>Guy C. Gordon<UNK! {0009}><UNK! {0009}>3194 Friar Tuck Way  |
  4. 13  '|<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>Doraville, GA 30340  |
  5. 14  '|<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>     |
  6. 16  '|<UNK! {0009}>This program takes the Unassemble output from DEBUG and changes<UNK! {0009}>     |
  7. 18  '|<UNK! {0009}>all Jump, Call and Loop addresses into labels of the form Lhhhh<UNK! {0009}>     |
  8. 20  '|<UNK! {0009}>where hhhh is the hex address.  All addresses are stripped from<UNK! {0009}>     |
  9. 22  '|<UNK! {0009}>the lines except those referenced in this block of code, which<UNK! {0009}>     |
  10. 24  '|<UNK! {0009}>are made into labels.   Your unassembled input file should con-<UNK! {0009}>     |
  11. 26  '|<UNK! {0009}>sist of all of the code and none of the data areas.<UNK! {0009}><UNK! {0009}>     |
  12. 28  '|<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>     |
  13. 30  '|<UNK! {0009}>In addition, blank lines are inserted after all unconditional <UNK! {0009}>     |
  14. 32  '|<UNK! {0009}>program transfers (JMP, JMPS, RET, IRET) to make the division of     |
  15. 34  '|<UNK! {0009}>the program into subroutines more visible.  Such lines are forced    |
  16. 35  '|<UNK! {0009}>to have labels, even if not referenced anywhere in the code.         |
  17. 36  '|<UNK! {0009}>A warning comment is appended in this case.<UNK! {0009}><UNK! {0009}><UNK! {0009}>     |
  18. 40  '|<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>     |
  19. 42  '|<UNK! {0009}>UASM-JMP replaces COM2ASM by Richard Winkel on which it is based.    |
  20. 44  '|<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>     |
  21. 46  '|<UNK! {0009}>Due to the large amount of disk I/O, this program will run fastest   |
  22. 48  '|<UNK! {0009}>with the input and output files on a RAM drive.  If you must put     |
  23. 49  '|<UNK! {0009}>both files on floppies, specify separate drives for input & output.  |
  24. 50  '********************************* NOTICE *********************************
  25. 51  '*          USER SUPPORTED SOFTWARE (With thanks to Andrew Flugelman)     *
  26. 52  '*                                                                        *
  27. 53  '*   A limited license is granted to all users of this program, to make   *
  28. 54  '*   copies of this program and distribute them to other users subject    *
  29. 55  '*   to the following conditions:                                         *
  30. 56  '*           1.  None of the notices or credits are to be bypassed,       *
  31. 57  '*               altered, or removed.                                     *
  32. 58  '*           2.  The program is not to be distributed in modified form.   *
  33. 59  '*               (Users are encouraged to distribute MERGE files.)        *
  34. 60  '*           3.  No fee is to be charged (or any other consideration      *
  35. 61  '*               received) for copying or distributing the program        *
  36. 62  '*               without an express written agreement with                *
  37. 63  '*               White Crane Systems.                                     *
  38. 64  '**************************************************************************
  39. 70  CLS 'PRINT CHR$(27)+"E";   'CLS<UNK! {0009}>'CLS for IBM, ESC E for Victor 9000
  40. 71  PRINT "                                UASM-JMP
  41. 72  PRINT "              White Crane Systems Unassembler - Jump Module
  42. 73  PRINT "
  43. 74  PRINT "           If you are using this program and finding it of value
  44. 75  PRINT "      please send  a cash contribution to support its upkeep and
  45. 76  PRINT "      distribution.   Use the UASM system  of programs to  unas-
  46. 77  PRINT "      semble one average length .COM file, look over the results
  47. 78  PRINT "      and calculate how many hours this would have taken you  to
  48. 79  PRINT "      to produce,  multiply by the minimum wage, contribute that
  49. 80  PRINT "      amount and use the programs free thereafter. If that's too
  50. 81  PRINT "      much just send $20.   Supporters will receive  free notice 
  51. 82  PRINT "      of enhancements and updates.
  52. 83  PRINT "           In any case you are encouraged to copy and distribute 
  53. 84  PRINT "      UASM to your friends provided you do so free of charge and
  54. 85  PRINT "      in unmodified form.
  55. 87  PRINT " 
  56. 88  PRINT "                          Guy C. Gordon
  57. 89  PRINT "                          White Crane Systems
  58. 90  PRINT "                          3194 Friar Tuck Way
  59. 91  PRINT "                          Doraville, GA 30340
  60. 92  '
  61. 100  <UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>'INITIALIZATION
  62. 110  DEFINT A-Z
  63. 120  DIM LIN$(999)
  64. 130  TRUE=(1=1): FALSE=NOT TRUE: BELL$=CHR$(7)
  65. 140  WARNING$=":<UNK! {0009}><UNK! {0009}>; WARNING!  No code for this label"
  66. 200  '
  67. 210  PRINT
  68. 220  INPUT "Enter name of input file [.DB]: ",INFILE$
  69. 230  <UNK! {0009}>DR=INSTR(INFILE$,":"): EXT=INSTR(INFILE$,".")
  70. 240  <UNK! {0009}>IF EXT=0 THEN INFILE$=INFILE$+".DB": EXT=INSTR(INFILE$,".")
  71. 250  <UNK! {0009}>ID$=MID$(INFILE$,DR+1,EXT-DR-1)
  72. 260  PRINT "Enter name of output file ["ID$".JMP]: ";: INPUT "", OUTFILE$
  73. 270  <UNK! {0009}>IF INSTR(OUTFILE$,":")=LEN(OUTFILE$) THEN OUTFILE$=OUTFILE$+ID$
  74. 280  <UNK! {0009}>IF INSTR(OUTFILE$,".")=0 THEN OUTFILE$=OUTFILE$+".JMP"
  75. 300  '
  76. 310  OPEN INFILE$ FOR INPUT AS #1
  77. 320  OPEN OUTFILE$ FOR OUTPUT AS #2
  78. 330  '
  79. 340  PRINT #2,"<UNK! {0009}>TITLE<UNK! {0009}>"ID$"<UNK! {0009}><UNK! {0009}><UNK! {0009}>"DATE$
  80. 350  PRINT #2,".RADIX<UNK! {0009}>16"
  81. 360  PRINT #2,
  82. 400  '-------------------------------------------------------------------------
  83. 401  '<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>READ INPUT FILE<UNK! {0009}><UNK! {0009}>(First pass)<UNK! {0009}>     |
  84. 402  '-------------------------------------------------------------------------
  85. 405  PRINT: PRINT "Pass 1:   Reading "INFILE$: T1$=TIME$
  86. 410  WHILE NOT EOF(1)
  87. 420    LINE INPUT #1,A$: IF LEN(A$)<28 THEN 480
  88. 425    '<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>look for various Jumps, CALL, or LOOP
  89. 430    IF MID$(A$,25,1)<>"J" AND MID$(A$,25,4)<>"CALL" AND MID$(A$,25,4)<>"LOOP" THEN 480
  90. 440    '<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>make certain we have found a hex address
  91. 450    IF MID$(A$,33,1)<"0" OR MID$(A$,33,1)>"F" OR MID$(A$,34,1)<"0" OR MID$(A$,34,1)>"F" OR MID$(A$,35,1)<"0" OR MID$(A$,35,1)>"F" OR MID$(A$,36,1)<"0" OR MID$(A$,36,1)>"F" OR MID$(A$,37,1)=":" THEN 480
  92. 455    '<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>skip termination or inter-segment jumps
  93. 460    IF MID$(A$,33,4)="0000" OR MID$(A$,37,1)=":" THEN 480
  94. 470    LIN=LIN+1: LIN$(LIN)=MID$(A$,33,4)<UNK! {0009}>'Found a reference
  95. 480  WEND
  96. 490  CLOSE #1<UNK! {0009}><UNK! {0009}><UNK! {0009}>'done with first pass
  97. 500  IF LIN>0 THEN 600
  98. 510  PRINT "No References found.  Check "INFILE$
  99. 520  PRINT "(If you used DEBUG under DOS 1.1 you may have TABS in the file.)
  100. 530  END
  101. 600  '-------------------------------------------------------------------------
  102. 601  '<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>SUPER SHELL SORT (Byte, May '83)<UNK! {0009}>     |
  103. 602  '-------------------------------------------------------------------------
  104. 605  T2$=TIME$
  105. 610  PRINT "Sorting:  ";<UNK! {0009}><UNK! {0009}>'sort referenced addresses
  106. 620  D=2^INT(LOG(LIN)/LOG(2))-1 
  107. 630  FOR I=1 TO LIN-D
  108. 640    IF LIN$(I)<=LIN$(I+D) THEN 700 ELSE T$=LIN$(I+D):LIN$(I+D)=LIN$(I)
  109. 650    IF I<=D THEN LIN$(I)=T$:GOTO 700
  110. 670    FOR J=I-D TO 1 STEP -D:IF T$>=LIN$(J) THEN 690 ELSE LIN$(J+D)=LIN$(J):NEXT
  111. 690    LIN$(J+D)=T$
  112. 700  NEXT I: PRINT ".";
  113. 710  D=INT(D/2):IF D>0 THEN 630 ELSE PRINT: PRINT
  114. 800  '-------------------------------------------------------------------------
  115. 801  '<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>ELIMINATE DUPLICATE REFERENCES<UNK! {0009}><UNK! {0009}>     |
  116. 802  '-------------------------------------------------------------------------
  117. 805  T3$=TIME$
  118. 810  I=1: FOR J=2 TO LIN
  119. 820    IF LIN$(I)=LIN$(J) THEN 840
  120. 830    I=I+1: IF J<>I THEN LIN$(I)=LIN$(J)
  121. 840  NEXT J
  122. 850  LIN=I
  123. 1000  '------------------------------------------------------------------------
  124. 1001  '<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>READ INPUT & WRITE OUTPUT  (Pass 2)<UNK! {0009}>     |
  125. 1002  '------------------------------------------------------------------------
  126. 1010  T4$=TIME$: L=1 <UNK! {0009}>'now go back thru file and plug in labels for addresses
  127. 1020  OPEN INFILE$ FOR INPUT AS #1
  128. 1030  FORCE.LABEL=TRUE<UNK! {0009}><UNK! {0009}>'First line is force labeled
  129. 1040  WHILE NOT EOF(1) 
  130. 1050    LINE INPUT #1, A$: IF LEN(A$)<28 THEN 1490
  131. 1100    '<UNK! {0009}><UNK! {0009}><UNK! {0009}>Label This Line?
  132. 1110    T$=MID$(A$,6,4)<UNK! {0009}><UNK! {0009}><UNK! {0009}>'offset of this line
  133. 1120    IF T$=LIN$(L) THEN MID$(A$,6,6)="L"+T$+":":  L=L+1:  FORCE.LABEL=FALSE:  GOTO 1200
  134. 1125    IF FORCE.LABEL AND T$="0100" THEN MID$(A$,6,6)="START:":FORCE.LABEL=FALSE: GOTO 1200
  135. 1130    IF FORCE.LABEL THEN MID$(A$,6,6)="L"+T$+":" ELSE MID$(A$,6,6)=SPACE$(6)
  136. 1150    IF T$<=LIN$(L) OR L>LIN THEN 1200
  137. 1160    PRINT BELL$:   PRINT "L";LIN$(L);WARNING$: PRINT
  138. 1170    PRINT #2,: PRINT #2, "L";LIN$(L);WARNING$: PRINT #2,
  139. 1190    L=L+1: GOTO 1120<UNK! {0009}><UNK! {0009}>'Loop back and test next reference
  140. 1200    '<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>Find reference in this line
  141. 1210    IF MID$(A$,25,1)<>"J" AND MID$(A$,25,4)<>"CALL" AND MID$(A$,25,4)<>"LOOP" THEN 1300
  142. 1220    IF MID$(A$,33,1)<"0" OR MID$(A$,33,1)>"F" OR MID$(A$,34,1)<"0" OR MID$(A$,34,1)>"F" OR MID$(A$,35,1)<"0" OR MID$(A$,35,1)>"F" OR MID$(A$,36,1)<"0" OR MID$(A$,36,1)>"F" OR MID$(A$,37,1)=":" THEN 1300
  143. 1230    A$=LEFT$(A$,32)+"L"+MID$(A$,33)<UNK! {0009}><UNK! {0009}>'Make destination addr. a label
  144. 1300    '<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>Test for "The Force"
  145. 1310    IF NOT FORCE.LABEL OR MID$(A$,9,3)="NOP" THEN 1400
  146. 1320    I=LEN(A$): WHILE MID$(A$,I,1)=" " AND I>26: I=I-1: WEND 'last non-blank
  147. 1330    A$=LEFT$(A$,I)+"<UNK! {0009}><UNK! {0009}>;WARNING!  This label not referenced"
  148. 1340    PRINT BELL$;
  149. 1350    FORCE.LABEL=FALSE
  150. 1400    '<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>FINALLY, print the thing
  151. 1410    I=LEN(A$): WHILE MID$(A$,I,1)=" " AND I>26: I=I-1: WEND<UNK! {0009}>'last non-blank
  152. 1420    PRINT #2, MID$(A$,6,6);"  ";MID$(A$,25,I-24)
  153. 1430    PRINT     MID$(A$,6,6);"  ";MID$(A$,25,I-24)
  154. 1440    IF MID$(A$,25,3)="JMP" THEN 1470<UNK! {0009}><UNK! {0009}><UNK! {0009}>'one blank line
  155. 1450    IF MID$(A$,25,3)<>"RET" AND MID$(A$,25,4)<>"IRET" THEN 1490
  156. 1460  <UNK! {0009}> PRINT #2,: PRINT #2,<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>'two blank lines
  157. 1470  <UNK! {0009}> PRINT #2,: PRINT
  158. 1480  <UNK! {0009}> FORCE.LABEL=TRUE<UNK! {0009}><UNK! {0009}>'Must have label after JMP(S) or (I)RET
  159. 1490  WEND
  160. 1500  '------------------------------------------------------------------------
  161. 1501  '<UNK! {0009}><UNK! {0009}><UNK! {0009}><UNK! {0009}>END and ERROR Checking<UNK! {0009}><UNK! {0009}><UNK! {0009}>     |
  162. 1502  '------------------------------------------------------------------------
  163. 1510  IF L>LIN THEN 1550
  164. 1520  PRINT BELL$: PRINT "Error: End Of File on "INFILE$"
  165. 1530  PRINT "The following refereces were not processed:": PRINT
  166. 1540  FOR I=L TO LIN: PRINT LIN$(I),: PRINT #2,"L";LIN$(I);WARNING$: NEXT
  167. 1550  PRINT: PRINT: PRINT " START"," PASS 1","  SORT","  DUPS"," PASS 2"
  168. 1560  PRINT T1$,T2$,T3$,T4$,TIME$
  169. 1570  CLOSE: END
  170. 2000  'End of program UASM-JMP
  171.